package com.biotools.meerkat;

import java.util.*;
import java.text.*;

public class Messages
{
    private static final String BUNDLE_NAME = "com.biotools.meerkat.messages";
    private static ResourceBundle resourceBundle;
    private static Locale currentLocale;
    static /* synthetic */ Class class$0;
    
    private static final ResourceBundle getResourceBundle() {
        if (Messages.resourceBundle == null) {
            try {
                final String s = "com.biotools.meerkat.messages";
                final Locale locale = getLocale();
                Class class$0;
                if ((class$0 = Messages.class$0) == null) {
                    try {
                        class$0 = (Messages.class$0 = Class.forName("com.biotools.meerkat.Messages"));
                    }
                    catch (ClassNotFoundException ex) {
                        throw new NoClassDefFoundError(ex.getMessage());
                    }
                }
                Messages.resourceBundle = ResourceBundle.getBundle(s, locale, class$0.getClassLoader());
            }
            catch (MissingResourceException e) {
                e.printStackTrace();
                setLocale(new Locale("en"));
            }
        }
        return Messages.resourceBundle;
    }
    
    public static String getString(final String patternKey, final Object[] messageArguments) {
        final MessageFormat formatter = new MessageFormat(getString(patternKey), getLocale());
        return formatter.format(messageArguments);
    }
    
    public static String getString(final String key) {
        try {
            return getResourceBundle().getString(key.trim());
        }
        catch (Exception e) {
            e.printStackTrace();
            return "!" + key + "!";
        }
    }
    
    public static Locale getLocale() {
        if (Messages.currentLocale == null) {
            setLocale();
        }
        return Messages.currentLocale;
    }
    
    public static void setLocale() {
        setLocale(Locale.getDefault());
    }
    
    public static void setLocale(final Locale newLocale) {
        Messages.currentLocale = newLocale;
    }
}
